<template>
	<view class="navbar" @click="open">
		<view class="navbar-fixed">

			<!-- 导航栏内容 -->
			<view class="navbar-content" :style="{height:navBarHeight+'px',width:navBarWidth+'px'}">
				<view class="hello">
					码农圈
				</view>
				<view class="tab-icons" @click ="open">
					
					<uni-icons type="search" size="28" color="#13227a" ></uni-icons>
				</view>
			</view>
		</view>
		<view :style="{height:statusBarHeight+navBarHeight+'px'}"></view>
	</view>
</template>

<script>
	export default {
		props:{
			// 判断是否再搜索状态
			isSearch:{
				type:Boolean,
				default:false
			}
		},
		name: "navbarIndex",
		data() {
			return {
				statusBarHeight: 20,
				navBarHeight: 45,
				windowWidth: 375

			};
		},
		methods: {
			open() {
				uni.navigateTo({
					url:"/pages/searchHome/searchHome"
				})
				console.log("sousuo");
			}
		},

		created() {
			//同步获取手机系统信息
			const info = uni.getSystemInfoSync()
			//设置状态栏高度(H5的状态栏高度是0)
			this.statusBarHeight = info.statusBarHeight
			this.navBarWidth = info.windowWidth
			// #ifndef H5 || APP-PLUS || MP-ALIPAY
			//H5 app mp-alipay 不支持uni.getMenuButtonBoundingClientRect()这个api
			//获取胶囊的位置信息
			const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
			//(胶囊底部高度-状态栏高度)+（胶囊顶部高度-状态栏高度）=导航栏高度
			this.navBarHeight = (menuButtonInfo.bottom - info.statusBarHeight) + (menuButtonInfo.top - inf
				.statusBarHeight) + 4
			//内容宽度
			this.navBarWidth = menuButtonInfo.left
			// #endif

		}

	}
</script>

<style lang="scss">
	@import "../../uni_modules/uni-icons/components/uni-icons/uniicons.css";

	.navbar {
		// margin-top: 20px;

		.statebar {
			height: 20px;
		}

		.navbar-fixed {
			position: fixed;
			top: 0;
			left: 0;
			z-index: 99;
			display: flex;
			justify-content: center;
			align-items: center;
			padding: 0 15px;
			width: 100%;
			height: 100upx;
			// background-color: $mk-base-color;
			background-image: linear-gradient();
			// 在盒内显示
			box-sizing: border-box;

			.navbar-content {
				display: flex;
				position: relative;
				justify-content: center; //水平居中
				align-items: center;
				padding: 0 15px;
				margin-top: 20px;
				// margin-bottom: 10px;
				width: 500px;
				box-sizing: border-box; //只在盒内显示

				.hello {
					position: absolute;
					// display: block;
					left: 0;
					top: 0;
					// padding: 30px;
					margin-top: 20px;
					// width: 100%;
					font-weight: 1000;
					font-size: 24px;
					color: $mk-base-color;
					box-sizing: border-box;
				}
				.tab-icons {
					display: flex;
					position: absolute;
					top:-40%;
					right: 0%;
					justify-content: center;
					align-items: center;
					justify-content: center;
					width: 35px;
					padding: 2px;
					// height: 35px;
					margin-top: 40px;
					// background-color: #f8fcfc;
					border-radius: 6px;
				
					// border: 1px #f3f3f3 solid;
					// border: 1px green solid;
				
				}
			}
			

		}

	}
</style>
